# -*- encoding: utf-8 -*-

set :root, ROOT_DIR
set :public_folder, ROOT_DIR + '/public'
set :logging, false

get '/' do
  File.read(ROOT_DIR + '/public/index.html')
end

def App.log(message)
end

App.on(:subscribe) do |client_id, channel|
  puts "[SUBSCRIBE] #{client_id} -> #{channel}"
  # if /\/notifications\/*/.match(channel)
  #   m = /\/notifications\/(?<access_token>\d+)/.match(channel)
  #   Redis.current.set("faye:#{m[:access_token]}:online_status", "1")
  # end
end

App.on(:unsubscribe) do |client_id, channel|
  puts "[UNSUBSCRIBE] #{client_id} -> #{channel}"
end

App.on(:publish) do |client_id, channel, data|
  puts "[PUBLISH] #{client_id} -> #{channel} -> #{data}"
end

App.on(:handshake) do |client_id|
  puts "[CONNECTED] #{client_id}"
end

App.on(:disconnect) do |client_id|
  puts "[DISCONNECT] #{client_id}"
end